home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DRIVES.SWG / 0005_DRIVE-ID.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  3KB  |  54 lines

  1. {
  2.  Below is TP code to do drive-Type identification.  I leave it as a
  3.  research exercise For you to create code to differentiate between
  4.  a RAM drive and fixed disk, if that's needed.
  5.  
  6. }
  7. (********************************************************************)
  8.  Program DrvCount;                      { coded by Greg Vigneault   }
  9.  Uses   Crt,Dos;                        { For MsDos Function        }
  10.  Var    Drives      :Byte;              { count of logical drives   }
  11.         Reg         :Registers;         { to access CPU Registers   }
  12.         ThisDrive   :Byte;              { loop count                }
  13.         DriveType   :String[16];        { Type of drive found       }
  14.         DataBuffer  :Array [0..127] of Byte;   { buffer For Dos i/o }
  15.  begin
  16.     ClrScr;                             { remove screen clutter     }
  17.     Reg.AH := $19;                      { get current disk code     }
  18.     MsDos(Reg);                         { via Dos                   }
  19.     Reg.DL := Reg.AL;                   { returned drive code       }
  20.     Reg.AH := $E;                       { select disk               }
  21.     MsDos(Reg);                         { via Dos                   }
  22.     Drives := Reg.AL;                   { number of logical drives  }
  23.  
  24.     WriteLn('Number of logical drives: ', Drives );
  25.  
  26.     Intr($11,Reg);                      { get system equipment flag }
  27.     if ( (Reg.AX and 1) <> 0 )          { any floppies installed?   }
  28.         then WriteLn('(physical floppy drives: ',
  29.                 (Reg.AX SHR 6) and 3, ')' );    { get bits 6&7      }
  30.  
  31.     For ThisDrive := 1 to Drives do begin   { scan all drives       }
  32.         Reg.AX := $440D;                { using generic I/O control }
  33.         Reg.CX := $860;                 { to get drive parameters   }
  34.         Reg.BL := ThisDrive;            { For this drive            }
  35.         Reg.DX := ofs(DataBuffer);      { Pointer to scratch buffer }
  36.         Reg.DS := Seg(DataBuffer);      {  in is DS:DX              }
  37.         MsDos(Reg);                     { thank you, Dos            }
  38.         Case ( DataBuffer[1] ) of       { which Type it is...       }
  39.             0   : DriveType := '360 KB 5.25" FDD';
  40.             1   : DriveType := '1.2 MB 5.25" FDD';
  41.             2   : DriveType := '720 KB 3.5" FDD';
  42.             3   : DriveType := 'SD 8"'; { a relic from CP/M roots   }
  43.             4   : DriveType := 'DD 8"'; {   ditto                   }
  44.             5   : DriveType := 'Fixed/RAM disk';    { HDD or RAM    }
  45.             6   : DriveType := 'Tape drive';    { a good investment }
  46.             7   : DriveType := '1.44 MB 3.5" FDD'  { or "other" drv }
  47.             else  DriveType := '???';   { anything else             }
  48.             end; { Case }
  49.         WriteLn(' - ', CHR(ThisDrive+64),': (', DriveType, ')' );
  50.         { further code could ID between RAM drive & HDD             }
  51.         end; { For }
  52.  end. { Program }
  53. (********************************************************************)
  54.